<template>
  <div style="width: 100%;height: 100%;">
    <Echart
      :options="options"
      :id="id"
      height="100%"
      width="100%"
    ></Echart>
  </div>
</template>

<script>
  import Echart from '@/common/echart'
  export default {
    data () {
      return {
        options: {},
      };
    },
    components: {
      Echart,
    },
    props: {
      cdata: {
        type: Object,
        default: () => ({})
      },
      id: {
        type: String
      }
    },
    watch: {
      cdata: {
        handler (newData) {
          this.options = {
            tooltip: {
              trigger: "axis",
            },
            legend: {
              data: newData.legendList,
              textStyle: {
                color: "#B4B4B4"
              },
              top: "4%"
            },
            grid: {
              left: "12%",
              bottom: "15%",
              top: "15%",
              width: "80%"
            },
            xAxis: {
              data: newData.xAxisList,
              axisLine: {
                lineStyle: {
                  color: "#B4B4B4"
                }
              },
              axisTick: {
                show: false
              }
            },
            yAxis: [
              {
                splitLine: { show: false },
                axisLine: {
                  lineStyle: {
                    color: "#B4B4B4"
                  }
                },
                axisLabel: {
                  formatter: "{value}"
                }
              },
            ],
            series: newData.seriesList,
          }
        },
        immediate: true,
        deep: true
      }
    }
  };
</script>

<style lang="scss" scoped>
</style>
